const express = require('express')
const router = express.Router()
const settingService = require('services/setting')

router.get('/', async (req, res, next) => {
  try {
    res.json(await settingService.getEditable())
  } catch (e) {
    next(e)
  }
})

router.put('/', async (req, res, next) => {
  try {
    await settingService.save(req.body)
    res.json({
      status: 'ok'
    })
  } catch (e) {
    next(e)
  }
})

module.exports = router